import java.util.Scanner;

/**
 * 密码截取
 * 最长的回文字符串长度
 * Created by JiaJia on 2019/6/24 0024.
 */
public class HuaWei030 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            String str=scanner.nextLine();
            String rstr=new StringBuilder(str).reverse().toString();
            System.out.println(findMaxSubstring(str,rstr));
        }scanner.close();
    }
    private static int findMaxSubstring(String a,String b){
        int aLen = a.length() + 1;
        int bLen = b.length() + 1;
        int max = 0;
        int x = 0;

        // 初始值都为0
        int[][] c = new int[aLen][bLen];

        for (int i = 1; i < aLen; i++) {
            for (int j = 1; j < bLen; j++) {
                if (a.charAt(i - 1) == b.charAt(j - 1)) {
                    c[i][j] = c[i - 1][j - 1] + 1;
                } else {
                    c[i][j] = 0;
                }

                if (c[i][j] > max) {
                    max = c[i][j];
                }
            }
        }

        return max;
    }
}